﻿using WLFramework.Data;
using WLFramework.Data.DataProvider;
using WLFramework.Data.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using WLFramework.Json;
using GenericHtml;
using SampleSite.Common;

namespace SampleSite
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            DbManager.DefaultConfiguration = "Default";
            GenericConfigure.CreateDbManager = () =>
            {
                return new DbManager(CommandHelper.WriteConfiguration);
            };

            GenericConfigure.Log = (user, table, action) =>
            {
                using (CommandHelper db = new CommandHelper(CommandMethod.Write))
                {
                    db.Context.dy_DynamicLog
                      .Insert(() => new dy_DynamicLog
                      {
                          UserId = user,
                          TableId = table,
                          Method = action
                      });
                }
            };

            GenericConfigure.Provider = new DynamicMetadataProvider();

            GenericConfigure.Configure();
        }

        protected void Session_Start(object sender, EventArgs e)
        {
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}